package singleton;

/**
 * 饿汉式
 *
 * 1. 构造方法私有
 * 2. 声明一个已初始化好的静态变量，并设置为私有
 * 3. 对外提供静态get方法获取该静态变量
 */
public class Singleton02 {
    private static final Singleton02 INSTANCE = new Singleton02();
    private Singleton02(){};

    public static Singleton02 getInstance(){
        return INSTANCE;
    }

    public static void main(String[] args) {
        Singleton02 i1 = Singleton02.getInstance();
        Singleton02 i2 = Singleton02.getInstance();
        System.out.println(i1 == i2);
    }
}
